/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.fallback.system;

import com.enation.app.javashop.core.client.feignimpl.system.MessageTemplateClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import com.enation.app.javashop.model.system.dos.MessageTemplateDO;
import com.enation.app.javashop.model.system.enums.MessageCodeEnum;
import com.enation.app.javashop.model.system.enums.WechatMsgTemplateTypeEnum;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 消息模版client断路器
 * @date 2018/9/27 9:44
 * @since v7.0.0
 */
@Component
public class MessageTemplateClientFallbackFactory extends BaseFallbackFactory<MessageTemplateClientFeignImpl> implements FallbackFactory {


    @Override
    protected MessageTemplateClientFeignImpl fallback() {
        return new MessageTemplateClientFallback();
    }

    /**
     * @author fk
     * @version v2.0
     * @Description: 消息模版client断路器
     * @date 2018/9/27 9:44
     * @since v7.0.0
     */
    @Component
    public static class MessageTemplateClientFallback implements MessageTemplateClientFeignImpl {

        protected final Log logger = LogFactory.getLog(this.getClass());

        @Override
        public MessageTemplateDO getModel(MessageCodeEnum messageCodeEnum) {

            this.logger.error("系统服务返回异常，获取消息模板异常");

            return new MessageTemplateDO();
        }

        @Override
        public void sendWechatMsg(Long memberId, WechatMsgTemplateTypeEnum messageType, List<Object> keywords) {
            this.logger.error("系统服务返回异常，sendWechatMsg 异常");
        }

    }
}
